package com.gateway;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.gateway.config.LoadBalancerProperties;
import org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.web.reactive.DispatcherHandler;

/**
 * @author 惊云
 * @date 2023/4/15 21:53
 */
@org.springframework.context.annotation.Configuration
@ConditionalOnClass({LoadBalancerClient.class, RibbonAutoConfiguration.class, DispatcherHandler.class})
@AutoConfigureAfter(RibbonAutoConfiguration.class)
@EnableConfigurationProperties(LoadBalancerProperties.class)
public class Configuration {

    @Bean
    @Primary
    public GatewayGrayFilter gatewayFilter(LoadBalancerClient client, LoadBalancerProperties properties) {
        return new GatewayGrayFilter(client, properties);
    }

}
